home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Asm / AB3DIIsrc / source_4000 / PLR2CONTROL.s < prev    next >
Encoding:
Text File  |  1996-07-06  |  9.8 KB  |  747 lines

  1.  
  2. PLR2_mouse_control
  3.  jsr ReadMouse
  4.  
  5.  move.l #SineTable,a0
  6.  move.w PLR2s_angspd,d1
  7.  move.w angpos,d0
  8.  and.w #8190,d0
  9.  move.w d0,PLR2s_angpos
  10.  move.w (a0,d0.w),PLR2s_sinval
  11.  adda.w #2048,a0
  12.  move.w (a0,d0.w),PLR2s_cosval
  13.  
  14.  move.l PLR2s_xspdval,d6
  15.  move.l PLR2s_zspdval,d7
  16.  
  17.  neg.l d6
  18.  ble.s .nobug1
  19.  asr.l #1,d6
  20.  add.l #1,d6
  21.  bra.s .bug1
  22. .nobug1
  23.  asr.l #1,d6
  24. .bug1:
  25.  
  26.  neg.l d7
  27.  ble.s .nobug2
  28.  asr.l #1,d7
  29.  add.l #1,d7
  30.  bra.s .bug2
  31. .nobug2
  32.  asr.l #1,d7
  33. .bug2: 
  34.  
  35.  move.w ymouse,d3
  36.  sub.w oldymouse,d3
  37.  add.w d3,oldymouse
  38. ; asr.w #1,d3
  39. ; cmp.w #50,d3
  40. ; ble.s .nofastfor
  41. ; move.w #50,d3
  42. ;.nofastfor:
  43. ; cmp.w #-50,d3
  44. ; bge.s .nofastback
  45. ; move.w #-50,d3
  46. ;.nofastback:
  47.  
  48.  move.w STOPOFFSET,d0
  49.  move.w d3,d2
  50.  asl.w #7,d2
  51.  
  52.  add.w d2,PLR2_AIMSPD
  53.  add.w d3,d0
  54.  cmp.w #-80,d0
  55.  bgt.s .nolookup
  56.  move.w #-512*20,PLR2_AIMSPD
  57.  move.w #-80,d0
  58. .nolookup:
  59.  cmp.w #80,d0
  60.  blt.s .nolookdown
  61.  move.w #512*20,PLR2_AIMSPD
  62.  move.w #80,d0
  63. .nolookdown
  64.  
  65.  move.w d0,STOPOFFSET
  66.  neg.w d0
  67.  add.w TOTHEMIDDLE,d0
  68.  move.w d0,SMIDDLEY
  69.  muls #320,d0
  70.  move.l d0,SBIGMIDDLEY
  71.  
  72.  move.l #KeyMap,a5
  73.  moveq #0,d7
  74.  move.b forward_key,d7
  75.  
  76.  btst #6,$bfe001
  77.  seq.s (a5,d7.w)
  78.  
  79.  move.b fire_key,d7
  80.  btst #2,$dff016
  81.  seq.s (a5,d7.w)
  82.  
  83.  bra PLR2_keyboard_control
  84.  
  85.  move.w #-20,d2
  86.  
  87.  tst.b PLR2_Squished
  88.  bne.s .halve
  89.  tst.b PLR2_Ducked
  90.  beq.s .nohalve
  91. .halve
  92.  asr.w #1,d2
  93. .nohalve
  94.  
  95.  btst #6,$bfe001
  96.  beq.s .moving
  97.  moveq #0,d2
  98. .moving:
  99.  
  100.  move.w d2,d3
  101.  asl.w #4,d2
  102.  move.w d2,d1
  103.  
  104.  move.w d1,ADDTOBOBBLE
  105.  
  106.  move.w PLR2s_sinval,d1
  107.  move.w PLR2s_cosval,d2
  108.  
  109.  move.w d2,d4
  110.  move.w d1,d5
  111.  muls lrs,d4
  112.  muls lrs,d5
  113.  
  114.  muls d3,d2
  115.  muls d3,d1
  116.  sub.l d4,d1
  117.  add.l d5,d2
  118.  
  119.  sub.l d1,d6
  120.  sub.l d2,d7
  121.  add.l d6,PLR2s_xspdval
  122.  add.l d7,PLR2s_zspdval
  123.  move.l PLR2s_xspdval,d6
  124.  move.l PLR2s_zspdval,d7
  125.  add.l d6,PLR2s_xoff
  126.  add.l d7,PLR2s_zoff
  127.  
  128.  tst.b PLR2_fire
  129.  beq.s .firenotpressed
  130. ; fire was pressed last time.
  131.  btst #6,$bfe001
  132.  bne.s .firenownotpressed
  133. ; fire is still pressed this time.
  134.  st PLR2_fire
  135.  bra .donePLR2
  136.  
  137. .firenownotpressed:
  138. ; fire has been released.
  139.  clr.b PLR2_fire
  140.  bra .donePLR2
  141.  
  142. .firenotpressed
  143.  
  144. ; fire was not pressed last frame...
  145.  
  146.  btst #6,$bfe001
  147. ; if it has still not been pressed, go back above
  148.  bne.s .firenownotpressed
  149. ; fire was not pressed last time, and was this time, so has
  150. ; been clicked.
  151.  st PLR2_clicked
  152.  st PLR2_fire
  153.  
  154. .donePLR2:
  155.  
  156.  bsr PLR2_fall
  157.  
  158.  rts
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186. PLR2_alwayskeys
  187.  move.l #KeyMap,a5
  188.  moveq #0,d7
  189.  
  190.  move.b next_weapon_key,d7
  191.  tst.b (a5,d7.w)
  192.  beq.s .nonextweappre
  193.  
  194. ; tst.b PLR2_GunFrame
  195. ; bne.s .nonextweappre
  196.  
  197.  tst.b gunheldlast
  198.  bne.s .nonextweap
  199.  st gunheldlast
  200.  
  201.  moveq #0,d0
  202.  move.b PLR2_GunSelected,d0
  203.  move.l #PLAYERTWOGUNS,a0
  204.  
  205. .findnext
  206.  addq #1,d0
  207.  cmp.w #9,d0
  208.  ble.s .okgun
  209.  moveq #0,d0
  210. .okgun:
  211.  tst.w (a0,d0.w*2)
  212.  beq.s .findnext
  213.  
  214.  move.b d0,PLR2_GunSelected 
  215.  bsr SHOWPLR2GUNNAME
  216.   
  217.  bra .nonextweap
  218.  
  219. .nonextweappre:
  220.  clr.b gunheldlast
  221. .nonextweap:
  222.  
  223.  
  224.  move.b operate_key,d7
  225.  move.b (a5,d7.w),d1
  226.  beq.s .nottapped
  227.  tst.b OldSpace
  228.  bne.s .nottapped
  229.  st PLR2_SPCTAP
  230. .nottapped:
  231.  move.b d1,OldSpace
  232.  
  233.  move.b duck_key,d7
  234.  tst.b (a5,d7.w)
  235.  beq.s .notduck
  236.  clr.b (a5,d7.w)
  237.  move.l #playerheight,PLR2s_targheight
  238.  not.b PLR2_Ducked
  239.  beq.s .notduck
  240.  move.l #playercrouched,PLR2s_targheight
  241. .notduck:
  242.  
  243.  move.l PLR2_Roompt,a4
  244.  move.l ToZoneFloor(a4),d0
  245.  sub.l ToZoneRoof(a4),d0
  246.  tst.b PLR2_StoodInTop
  247.  beq.s .usebottom
  248.  move.l ToUpperFloor(a4),d0
  249.  sub.l ToUpperRoof(a4),d0
  250. .usebottom:
  251.  
  252.  clr.b PLR2_Squished
  253.  move.l #playerheight,PLR2s_SquishedHeight
  254.  
  255.  cmp.l #playerheight+3*1024,d0
  256.  bgt.s oktostand2
  257.  st PLR2_Squished
  258.  move.l #playercrouched,PLR2s_SquishedHeight
  259. oktostand2:
  260.  
  261.  move.l PLR2s_targheight,d1
  262.  move.l PLR2s_SquishedHeight,d0
  263.  cmp.l d0,d1
  264.  blt.s .notsqu
  265.  move.l d0,d1
  266. .notsqu:
  267.  
  268.  move.l PLR2s_height,d0
  269.  cmp.l d1,d0
  270.  beq.s .noupordown
  271.  bgt.s .crouch
  272.  add.l #1024,d0
  273.  bra .noupordown
  274. .crouch:
  275.  sub.l #1024,d0
  276. .noupordown:
  277.  move.l d0,PLR2s_height
  278.  
  279.  tst.b $27(a5)
  280.  beq.s .notselkey
  281.  st PLR2KEYS
  282.  clr.b PLR2PATH
  283.  clr.b PLR2MOUSE
  284.  clr.b PLR2JOY
  285. .notselkey:
  286.  
  287.  tst.b $26(a5)
  288.  beq.s .notseljoy
  289.  clr.b PLR2KEYS
  290.  clr.b PLR2PATH
  291.  clr.b PLR2MOUSE
  292.  st PLR2JOY
  293. .notseljoy:
  294.  
  295.  tst.b $37(a5)
  296.  beq.s .notselmouse
  297.  clr.b PLR2KEYS
  298.  clr.b PLR2PATH
  299.  st PLR2MOUSE
  300.  clr.b PLR2JOY
  301. .notselmouse:
  302.  
  303.  lea 1(a5),a4
  304.  move.l #PLAYERTWOGUNS,a2
  305.  move.l PLR2_Obj,a3
  306.  move.w #9,d1
  307.  move.w #0,d2
  308. pickweap2
  309.  move.w (a2)+,d0
  310.  and.b (a4)+,d0
  311.  beq.s notgotweap2
  312.  move.b d2,PLR2_GunSelected
  313.  move.w #0,ObjTimer+64(a3)
  314.  
  315. ; move.l #TEMPSCROLL,SCROLLPOINTER
  316. ; move.w #0,SCROLLXPOS
  317. ; move.l #TEMPSCROLL+160,ENDSCROLL
  318. ; move.w #40,SCROLLTIMER
  319.  
  320. ; d2=number of gun.
  321.  
  322.  bsr SHOWPLR2GUNNAME
  323.  
  324.  bra.s gogogogog
  325.  
  326. notgotweap2
  327.  addq #1,d2
  328.  dbra d1,pickweap2
  329.  
  330. gogogogog:
  331.  
  332.  ifeq CHEESEY
  333.  
  334.  tst.b $43(a5)
  335.  beq.s .notswapscr
  336.  tst.b lastscr
  337.  bne.s .notswapscr2
  338.  st lastscr
  339.  
  340.  not.b FULLSCRTEMP
  341.  
  342.  bra.s .notswapscr2
  343.  
  344. .notswapscr:
  345.  clr.b lastscr
  346. .notswapscr2:
  347.  
  348.  endc
  349.  
  350.  rts
  351.  
  352. SHOWPLR2GUNNAME:
  353.  moveq #0,d2
  354.  move.b PLR2_GunSelected,d2
  355.  
  356.  move.l LINKFILE,a4
  357.  add.l #GunNames,a4
  358.  muls #20,d2
  359.  add.l d2,a4
  360.  move.l #TEMPSCROLL,a2
  361.  move.w #19,d2
  362.  
  363. .copyname:
  364.  move.b (a4)+,d3
  365.  bne.s .oklet
  366.  move.b #32,d3
  367. .oklet:
  368.  move.b d3,(a2)+
  369.  
  370.  dbra d2,.copyname
  371.  
  372.  move.l #TEMPSCROLL,d0
  373.  jsr SENDMESSAGENORET
  374.  rts
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419. TURNSPD: dc.w 0
  420.  
  421. PLR2_keyboard_control:
  422.  
  423.  move.l #SineTable,a0
  424.  
  425.  jsr PLR2_alwayskeys
  426.  move.l #KeyMap,a5
  427.  
  428.  move.w STOPOFFSET,d0
  429.  moveq #0,d7
  430.  move.b look_up_key,d7
  431.  tst.b (a5,d7.w)
  432.  beq.s .nolookup
  433.  
  434.  sub.w #512,PLR2_AIMSPD
  435.  sub.w #4,d0
  436.  cmp.w #-80,d0
  437.  bgt.s .nolookup
  438.  move.w #-512*20,PLR2_AIMSPD
  439.  move.w #-80,d0
  440. .nolookup:
  441.  moveq #0,d7
  442.  move.b look_down_key,d7
  443.  tst.b (a5,d7.w)
  444.  beq.s .nolookdown
  445.  add.w #512,PLR2_AIMSPD
  446.  add.w #4,d0
  447.  cmp.w #80,d0
  448.  blt.s .nolookdown
  449.  move.w #512*20,PLR2_AIMSPD
  450.  move.w #80,d0
  451. .nolookdown:
  452.  
  453.  move.b centre_view_key,d7
  454.  tst.b (a5,d7.w)
  455.  beq.s .nocent
  456.  
  457.  tst.b OLDCENT
  458.  bne.s .nocent2
  459.  st OLDCENT
  460.  
  461.  move.w #0,d0
  462.  move.w #0,PLR2_AIMSPD
  463.  
  464.  bra.s .nocent2
  465.  
  466. .nocent:
  467.  clr.b OLDCENT
  468. .nocent2:
  469.  
  470.  
  471.  move.w d0,STOPOFFSET
  472.  neg.w d0
  473.  add.w TOTHEMIDDLE,d0
  474.  move.w d0,SMIDDLEY
  475.  muls #320,d0
  476.  move.l d0,SBIGMIDDLEY
  477.  
  478.  move.w PLR2s_angpos,d0
  479.  move.w PLR2s_angspd,d3
  480.  move.w #35,d1
  481.  move.w #2,d2
  482.  move.w #10,TURNSPD
  483.  moveq #0,d7
  484.  move.b run_key,d7
  485.  tst.b (a5,d7.w)
  486.  beq.s .nofaster
  487.  move.w #60,d1
  488.  move.w #3,d2
  489.  move.w #14,TURNSPD
  490. .nofaster:
  491.  tst.b PLR2_Squished
  492.  bne.s .halve
  493.  tst.b PLR2_Ducked
  494.  beq.s .nohalve
  495. .halve:
  496.  asr.w #1,d2
  497. .nohalve
  498.  
  499.  moveq #0,d4 
  500.  
  501.  tst.b SLOWDOWN
  502.  beq.s .nofric
  503.  move.w d3,d5
  504.  add.w d5,d5
  505.  add.w d5,d3
  506.  asr.w #2,d3
  507.  bge.s .nneg
  508.  addq #1,d3
  509. .nneg:
  510. .nofric:
  511.  
  512.  move.b turn_left_key,templeftkey
  513.  move.b turn_right_key,temprightkey
  514.  move.b sidestep_left_key,tempslkey
  515.  move.b sidestep_right_key,tempsrkey
  516.  
  517.  move.b force_sidestep_key,d7
  518.  tst.b (a5,d7.w)
  519.  beq .noalwayssidestep
  520.  
  521.  move.b templeftkey,tempslkey
  522.  move.b temprightkey,tempsrkey
  523.  move.b #255,templeftkey
  524.  move.b #255,temprightkey
  525.  
  526. .noalwayssidestep:
  527.  
  528.  tst.b SLOWDOWN
  529.  beq.s noturnposs2
  530.  
  531.  
  532.  move.b templeftkey,d7
  533.  tst.b (a5,d7.w)
  534.  beq.s .noleftturn
  535.  sub.w TURNSPD,d3
  536. .noleftturn
  537.  move.l #KeyMap,a5
  538.  move.b temprightkey,d7
  539.  tst.b (a5,d7.w)
  540.  beq.s .norightturn
  541.  add.w TURNSPD,d3
  542. .norightturn
  543.  
  544.  cmp.w d1,d3
  545.  ble.s .okrspd
  546.  move.w d1,d3
  547. .okrspd:
  548.  neg.w d1
  549.  cmp.w d1,d3
  550.  bge.s .oklspd
  551.  move.w d1,d3
  552. .oklspd:
  553.  
  554. noturnposs2:
  555.  
  556.  add.w d3,d0
  557.  add.w d3,d0
  558.  move.w d3,PLR2s_angspd
  559.  
  560.  move.b tempslkey,d7
  561.  tst.b (a5,d7.w)
  562.  beq.s .noleftslide
  563.  add.w d2,d4
  564.  add.w d2,d4
  565.  asr.w #1,d4
  566. .noleftslide
  567.  move.l #KeyMap,a5
  568.  move.b tempsrkey,d7
  569.  tst.b (a5,d7.w)
  570.  beq.s .norightslide
  571.  add.w d2,d4
  572.  add.w d2,d4
  573.  asr.w #1,d4
  574.  neg.w d4
  575. .norightslide
  576.   
  577. noslide2:
  578.   
  579.  and.w #8191,d0
  580.  move.w d0,PLR2s_angpos
  581.  
  582.  move.w (a0,d0.w),PLR2s_sinval
  583.  adda.w #2048,a0
  584.  move.w (a0,d0.w),PLR2s_cosval
  585.  
  586.  move.l PLR2s_xspdval,d6
  587.  move.l PLR2s_zspdval,d7
  588.  
  589.  tst.b SLOWDOWN
  590.  beq.s .nofriction
  591.  
  592.  neg.l d6
  593.  ble.s .nobug1
  594.  asr.l #3,d6
  595.  add.l #1,d6
  596.  bra.s .bug1
  597. .nobug1
  598.  asr.l #3,d6
  599. .bug1:
  600.  
  601.  neg.l d7
  602.  ble.s .nobug2
  603.  asr.l #3,d7
  604.  add.l #1,d7
  605.  bra.s .bug2
  606. .nobug2
  607.  asr.l #3,d7
  608. .bug2: 
  609.  
  610. .nofriction
  611.  
  612.  moveq #0,d3
  613.  
  614.  moveq #0,d5
  615.  move.b forward_key,d5
  616.  tst.b (a5,d5.w)
  617.  beq.s .noforward
  618.  neg.w d2
  619.  move.w d2,d3
  620.  
  621. .noforward:
  622.  move.b backward_key,d5
  623.  tst.b (a5,d5.w)
  624.  beq.s .nobackward
  625.  move.w d2,d3
  626. .nobackward:
  627.  
  628.  move.w d3,d2
  629.  asl.w #6,d2
  630.  move.w d2,d1
  631. ; add.w d2,d1
  632. ; add.w d2,d1
  633.  move.w d1,ADDTOBOBBLE
  634.  
  635.  move.w PLR2s_sinval,d1
  636.  muls d3,d1
  637.  move.w PLR2s_cosval,d2
  638.  muls d3,d2
  639.  
  640.  sub.l d1,d6
  641.  sub.l d2,d7
  642.  move.w PLR2s_sinval,d1
  643.  muls d4,d1
  644.  move.w PLR2s_cosval,d2
  645.  muls d4,d2
  646.  sub.l d2,d6
  647.  add.l d1,d7
  648.  
  649.  tst.b SLOWDOWN
  650.  beq.s .nocontrolposs
  651.  add.l d6,PLR2s_xspdval
  652.  add.l d7,PLR2s_zspdval
  653. .nocontrolposs:
  654.  move.l PLR2s_xspdval,d6
  655.  move.l PLR2s_zspdval,d7
  656.  add.l d6,PLR2s_xoff
  657.  add.l d7,PLR2s_zoff
  658.  
  659.  move.b fire_key,d5
  660.  tst.b PLR2_fire
  661.  beq.s .firenotpressed
  662. ; fire was pressed last time.
  663.  tst.b (a5,d5.w)
  664.  beq.s .firenownotpressed
  665. ; fire is still pressed this time.
  666.  st PLR2_fire
  667.  bra .doneplr2
  668.  
  669. .firenownotpressed:
  670. ; fire has been released.
  671.  clr.b PLR2_fire
  672.  bra .doneplr2
  673.  
  674. .firenotpressed
  675.  
  676. ; fire was not pressed last frame...
  677.  
  678.  tst.b (a5,d5.w)
  679. ; if it has still not been pressed, go back above
  680.  beq.s .firenownotpressed
  681. ; fire was not pressed last time, and was this time, so has
  682. ; been clicked.
  683.  st PLR2_clicked
  684.  st PLR2_fire
  685.  
  686. .doneplr2:
  687.  
  688.  bsr PLR2_fall
  689.  
  690.  rts
  691.  
  692.  
  693.   
  694. PLR2_JoyStick_control:
  695.  
  696.  jsr _ReadJoy2
  697.  bra PLR2_keyboard_control
  698.  
  699. PLR2_clumptime: dc.w 0
  700.  
  701. PLR2clump:
  702.  
  703.  movem.l d0-d7/a0-a6,-(a7)
  704.  move.l PLR2_Roompt,a0
  705.  move.w ToFloorNoise(a0),d0
  706.  
  707.  move.l ToZoneWater(a0),d1
  708.  cmp.l ToZoneFloor(a0),d1
  709.  bge.s THERESNOWATER2
  710.  
  711.  cmp.l PLR2_yoff,d1
  712.  blt.s THERESNOWATER2
  713.  
  714.  tst.b PLR2_StoodInTop
  715.  bne.s THERESNOWATER2
  716.  
  717.  move.w #6,d0
  718.  bra.s THERESWATER2
  719.  
  720. THERESNOWATER2:
  721.  
  722.  tst.b PLR2_StoodInTop
  723.  beq.s .okinbot
  724.  move.w ToUpperFloorNoise(a0),d0
  725. .okinbot:
  726.  
  727.  move.l LINKFILE,a0
  728.  add.l #FloorData,a0
  729.  move.w 2(a0,d0.w*4),d0    ; sample number.
  730.  
  731.  subq #1,d0
  732.  blt.s nofootsound2
  733.  
  734. THERESWATER2:
  735.  move.w d0,Samplenum
  736.  move.w #0,Noisex
  737.  move.w #100,Noisez
  738.  move.w #80,Noisevol
  739.  move.w #$fff8,IDNUM
  740.  clr.b notifplaying
  741.  move.b PLR2_Echo,SourceEcho
  742.  jsr MakeSomeNoise
  743.  
  744. nofootsound2:
  745.  movem.l (a7)+,d0-d7/a0-a6
  746.  
  747.  rts